package com.peng.utils.log;

import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;

import java.io.File;

/**
 * CustomTimeRollingPolicy
 * log配置, 根据环境设置
 *
 * @author: lupeng6
 * @create: 2020/2/17 17:30
 */
public class CustomTimeRollingPolicy extends FixedWindowRollingPolicy {


    @Override
    public void start() {
        this.setMinIndex(1);
        this.setMaxIndex(this.getMaxWindowSize());

        String logHome = "/home/work/logs/supervisor";
        if (new File(logHome).exists()) {
            this.setFileNamePattern(logHome + "/app.%i.log");
        } else {
            this.setFileNamePattern("./logs/app.%i.log");
        }
        super.start();
    }
}
